/**
 * 
 */
package edu.jvn.ict.locationsharing;

import java.io.Serializable;
import java.util.Random;

/**
 * 
 */
public class MemberInfo implements Comparable<MemberInfo> , Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2L;
	public static final int OFFLINE = 0;
	public static final int ONLINE = 1;

	private long id;
	private long joiningTimestamp;
	private long phoneNumber;
	private int ip;
	private int port;
	private GPSCoordinate gpsCoordinate;
	private long gpsTimestamp;
	private int nodeStatus;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getJoiningTimestamp() {
		return joiningTimestamp;
	}

	public void setJoiningTimestamp(long joiningTimestamp) {
		this.joiningTimestamp = joiningTimestamp;
	}

	public long getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(long phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public int getIp() {
		return ip;
	}

	public void setIp(int ip) {
		this.ip = ip;
	}

	public GPSCoordinate getGpsCoordinate() {
		//return gpsCoordinate;
		return this.gpsCoordinate;
	}

	public void setGpsCoordinate(GPSCoordinate gpsCoordinate) {
		this.gpsCoordinate = gpsCoordinate;
	}

	public long getGpsTimestamp() {
		return gpsTimestamp;
	}

	public void setGpsTimestamp(long gpsTimestamp) {
		this.gpsTimestamp = gpsTimestamp;
	}

	public void setNodeStatus(int nodeStatus) {
		this.nodeStatus = nodeStatus;
	}

	public int getNodeStatus() {
		return nodeStatus;
	}

	@Override
	public int compareTo(MemberInfo another) {
		if (joiningTimestamp < another.joiningTimestamp) {
			return -1;
		} else if (joiningTimestamp > another.joiningTimestamp) {
			return 1;
		} else if (phoneNumber < another.phoneNumber) {
			return -1;
		} else if (phoneNumber > another.phoneNumber) {
			return 1;
		} else {
			return 0;
		}
	}

	public String toString() {
		if (gpsCoordinate != null) {
			return Long.toString(id) + " : "
					+ Double.toString(gpsCoordinate.getLatitude()) + " - "
					+ Double.toString(gpsCoordinate.getLongitude());
		} else {
			return Long.toString(id) + " : " + "no gps";
		}
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

}
